package csu.web.credit_bank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import csu.web.credit_bank.pojo.Liked;
import csu.web.credit_bank.service.LikedService;
import csu.web.credit_bank.mapper.LikedMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 于欣淇
* @description 针对表【liked】的数据库操作Service实现
* @createDate 2025-07-09 09:57:47
*/
@Service
public class LikedServiceImpl extends ServiceImpl<LikedMapper, Liked>
    implements LikedService{

    @Autowired
    private LikedMapper likedMapper;

    @Override
    public Boolean getLiked(String postId, String userId) {
        QueryWrapper<Liked> likedQueryWrapper = new QueryWrapper<>();
        likedQueryWrapper.eq("post_id", postId);
        likedQueryWrapper.eq("user_id", userId);
        Liked existingLikedRecord = likedMapper.selectOne(likedQueryWrapper);
        return existingLikedRecord != null;
    }
}




